﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Init {
    import Engine.Classes.*;
    import flash.events.*;
    import Engine.Events.*;

    public class SNAPIInit extends SocialNetworkInit {

        protected var m_sn:SNAPISocialNetwork;
        protected var m_snClass:Class = null;

        public function SNAPIInit(_arg1:Boolean, _arg2:Class=null){
            if (_arg2 == null){
                _arg2 = SNAPISocialNetwork;
            };
            this.m_snClass = _arg2;
            super(_arg1);
        }
        override public function execute():void{
            if (m_skipSN){
                super.execute();
            } else {
                GlobalEngine.socialNetwork = (GlobalEngine.socialNetwork = (this.m_sn = new this.m_snClass()));
                this.m_sn.addEventListener(SocialNetworkEvent.GET_USER_COMPLETE, this.onGetUserComplete);
                this.m_sn.getUser();
                GlobalEngine.zaspManager.trackTimingStart("SN_INIT");
            };
        }
        private function onGetUserComplete(_arg1:SocialNetworkEvent):void{
            this.m_sn.removeEventListener(SocialNetworkEvent.GET_USER_COMPLETE, this.onGetUserComplete);
            dispatchEvent(new Event(Event.COMPLETE));
            GlobalEngine.zaspManager.trackTimingStop("SN_INIT");
            this.m_sn.addEventListener(SocialNetworkEvent.GET_FRIENDS_COMPLETE, this.onGetFriendsComplete);
            this.m_sn.getFriendList();
        }
        private function onGetFriendsComplete(_arg1:SocialNetworkEvent):void{
            this.m_sn.removeEventListener(SocialNetworkEvent.GET_FRIENDS_COMPLETE, this.onGetFriendsComplete);
            this.m_sn.addEventListener(SocialNetworkEvent.GET_APP_FRIENDS_COMPLETE, this.onGetAppFriendsComplete);
            this.m_sn.getAppFriends();
        }
        private function onGetAppFriendsComplete(_arg1:SocialNetworkEvent):void{
            this.m_sn.removeEventListener(SocialNetworkEvent.GET_APP_FRIENDS_COMPLETE, this.onGetAppFriendsComplete);
            this.setupOnFriendsComplete();
        }
        protected function setupOnFriendsComplete():void{
        }

    }
}//package Init 
